package com.sfh.dog;

import java.util.HashMap;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap.Config;

import cn.bmob.v3.Bmob;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.sfh.dog.entity.Daily;
import com.sfh.dog.ui.AddDogActivity;
import com.sfh.dog.ui.DailyActivity;
import com.sfh.dog.ui.EditDogActivity;
import com.sfh.dog.ui.LookDogActivity;
import com.sfh.dog.util.PhotoUtil;

public class DogApplication extends Application
{

	public static int widthItem = 60;
	public static DisplayImageOptions options = new DisplayImageOptions.Builder()
			.bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
			.showImageOnFail(R.drawable.latest_img_bg)
			.showImageOnLoading(R.drawable.latest_img_bg)
			.imageScaleType(ImageScaleType.EXACTLY).build();

	@Override
	public void onCreate()
	{
		super.onCreate();
		initConfig();
		initImageLoader(this);
		setFace();

	}
	
	private void initConfig()
	{
	    Bmob.initialize(this, "082a8e8c6e3c813c4b98bb41d795146f");
	}

	public static void initImageLoader(Context context)
	{
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				context).threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.discCacheFileNameGenerator(new Md5FileNameGenerator())
				.tasksProcessingOrder(QueueProcessingType.LIFO)
				.writeDebugLogs().build();
		ImageLoader.getInstance().init(config);
	}
//
//	/** 注册 */
//	public static void gotoRegUI(Activity activity, int requestCode)
//	{
//		Intent intent = new Intent(activity, UserRegActivity.class);
//		activity.startActivityForResult(intent, requestCode);
//	}
//
//	/** 注册 */
//	public static void gotoRegUI(Fragment fragment, int requestCode)
//	{
//		Intent intent = new Intent(fragment.getActivity(),
//				UserRegActivity.class);
//		fragment.startActivityForResult(intent, requestCode);
//	}
//
	/**
	 * 添加dog
	 * 
	 */
	public static void gotoAddDogUI(Context mContext)
	{
		Intent intent = new Intent(mContext, AddDogActivity.class);
		mContext.startActivity(intent);
	}

	/**
	 * 编辑dog
	 * 
	 */
	public static void gotoEditDogUI(Context mContext, String dogID)
	{
		Intent intent = new Intent(mContext,
				EditDogActivity.class);
		intent.putExtra(EditDogActivity.DOGID, dogID);
		mContext.startActivity(intent);
	}

	/**
	 * 查看dog
	 * @param activity
	 * @param dogID
	 */
	public static void gotoLookADogUI(Context activity, String dogID)
	{
		Intent intent = new Intent(activity, LookDogActivity.class);
		intent.putExtra(LookDogActivity.Key, dogID);
		activity.startActivity(intent);
	}
//
//	public static void gotoMainUI(Activity activity)
//	{
//		Intent intent = new Intent(activity, DogMainUI.class);
//		activity.startActivity(intent);
//	}
//
//	public static void gotoAddDailycontentUI(Activity activity, int requestCode)
//	{
//		Intent intent = new Intent(activity, AddDailyContentActivity.class);
//		activity.startActivityForResult(intent, requestCode);
//	}
//
//	public static void gotoEditDailycontentUI(Activity activity,
//			int requestCode, DailyContentEntity entity)
//	{
//		Intent intent = new Intent(activity, EditDailyContentActivity.class);
//		intent.putExtra(EditDailyContentActivity.KEY, entity);
//		activity.startActivityForResult(intent, requestCode);
//	}
//
	/**
	 * 详情
	 * @param context
	 * @param entity
	 */
	public static void gotoDailyDetailUI(Context context, Daily entity)
	{
		Intent intent = new Intent(context, DailyActivity.class);
		intent.putExtra(DailyActivity.KEY, entity);
		context.startActivity(intent);
	}
//
//	public static void gotoAddDaily(Activity activity)
//	{
//		Intent intent = new Intent(activity, AddDailyActivity.class);
//		activity.startActivity(intent);
//	}
//
//	public static void gotoImageSendUI(Activity activity, String path,
//			int requestCode)
//	{
//		Intent intent = new Intent(activity, SendFileActivity.class);
//		intent.putExtra(SendFileActivity.PATH, path);
//		activity.startActivityForResult(intent, requestCode);
//	}
//
//	public static void gotoLookImageUI(Context activity,
//			ArrayList<String> eList)
//	{
//		/*Intent intent = new Intent(activity, LookPictureActivity.class);
//		intent.putStringArrayListExtra(LookPictureActivity.KEY, eList);
//		activity.startActivity(intent);*/
//	}
//	
//
//	public static void gotoBlogUI(Context activity, String dogID)
//	{
//		Intent intent = new Intent(activity, BlogActivity.class);
//		intent.putExtra(BlogActivity.KEY, dogID);
//		activity.startActivity(intent);
//	}
//	
//	public static void gotoAboutUI(Context activity)
//	{
//		Intent intent = new Intent(activity, AboutUI.class);
//		activity.startActivity(intent);
//	}
//	
//	public static void gotoAboutMeUI(Context activity)
//	{
//		Intent intent = new Intent(activity, AboutMeUI.class);
//		activity.startActivity(intent);
//	}
//
//
//	/**
//	 * 送礼物
//	 * @param activity
//	 * @param dogID
//	 */
//	public static void gotoDogGift(Context activity,String dogID)
//	{
//		Intent intent = new Intent(activity, DogMedalListActivity.class);
//		intent.putExtra(DogMedalListActivity.KEY_DATA, dogID);
//		intent.putExtra(DogMedalListActivity.KEY_TYPE, 0);
//		activity.startActivity(intent);
//	}
//	
//	/**
//	 * 领取勋章
//	 * @param activity
//	 * @param dogID
//	 */
//	public static void gotoDogMedal(Context activity,String dogID)
//	{
//		Intent intent = new Intent(activity, DogMedalListActivity.class);
//		intent.putExtra(DogMedalListActivity.KEY_DATA, dogID);
//		intent.putExtra(DogMedalListActivity.KEY_TYPE, 1);
//		activity.startActivity(intent);
//	}

	
//	public static void share(Activity activity)
//	{
//		UMSocialService controller = UMServiceFactory.getUMSocialService(
//				"分享", RequestType.SOCIAL);
//	//	controller.getConfig().setSsoHandler(new SinaSsoHandler());
//		controller.getConfig().setSsoHandler(new TencentWBSsoHandler());
//		
//
//		// 设置分享图片
//		controller.setShareImage(new UMImage(activity, R.drawable.ic_launcher));
//		// 我们的微信appid wxdaf6dbbe6cedbb82
//		String wxAppId = "wx0d1ad552d0b385f5";
//
//		// 微信图文分享必须设置一个url
//		String contentUrl = "";
//		// 添加微信平台
//		controller.getConfig().supportWXPlatform(activity, wxAppId, contentUrl);
//
//		UMImage mUMImgBitmap = new UMImage(activity, R.drawable.ic_launcher);
//		mUMImgBitmap.setTitle(activity.getResources().getString(
//				R.string.app_name));
//		// target url 必须填写
//		mUMImgBitmap.setTargetUrl(contentUrl);
//
//		// 设置分享文字
//		controller.setShareContent("宠物日记，天天晒萌");
//		controller.setShareMedia(mUMImgBitmap);
//		// 支持微信朋友圈
//		controller.getConfig().supportWXCirclePlatform(activity, wxAppId,
//				contentUrl);
//
//		// 去除其他不必要的分享
//		controller.getConfig().removePlatform(SHARE_MEDIA.EMAIL);
////		controller.getConfig().removePlatform(SHARE_MEDIA.QZONE);
//		controller.getConfig().removePlatform(SHARE_MEDIA.RENREN);
//		controller.getConfig().removePlatform(SHARE_MEDIA.SMS);
////		controller.getConfig().removePlatform(SHARE_MEDIA.TWITTER);
//		controller.getConfig().removePlatform(SHARE_MEDIA.FACEBOOK);
//		controller.getConfig().removePlatform(SHARE_MEDIA.DOUBAN);
//		controller.openShare(activity, false);
//	}

	public static final int[] heads = { R.drawable.bab, R.drawable.bait,
			R.drawable.bugx, R.drawable.buy, R.drawable.car, R.drawable.ciy,
			R.drawable.cloud, R.drawable.dah, R.drawable.dang,
			R.drawable.daodg, R.drawable.dax, R.drawable.dog, R.drawable.fad,
			R.drawable.fangdj, R.drawable.feiw, R.drawable.fengy,
			R.drawable.ganb, R.drawable.ganm, R.drawable.good, R.drawable.guil,
			R.drawable.guz, R.drawable.hany, R.drawable.heil, R.drawable.huaix,
			R.drawable.hudj, R.drawable.jiay, R.drawable.jinge, R.drawable.kaf,
			R.drawable.kaih, R.drawable.kaixg, R.drawable.kes, R.drawable.know,
			R.drawable.ku, R.drawable.kul, R.drawable.lip, R.drawable.liul,
			R.drawable.liw, R.drawable.luoy, R.drawable.mam };

	public static HashMap<Integer, String> mFace = new HashMap<Integer, String>();

	public void setFace()
	{

		mFace.put(R.drawable.bab, "[a]");
		mFace.put(R.drawable.bait, "[b]");
		mFace.put(R.drawable.bugx, "[c]");
		mFace.put(R.drawable.buy, "[d]");
		mFace.put(R.drawable.car, "[e]");
		mFace.put(R.drawable.ciy, "[f]");
		mFace.put(R.drawable.cloud, "[g]");
		mFace.put(R.drawable.dah, "[h]");
		mFace.put(R.drawable.dang, "[i]");
		mFace.put(R.drawable.daodg, "[j]");
		mFace.put(R.drawable.dax, "[k]");
		mFace.put(R.drawable.dog, "[m]");
		mFace.put(R.drawable.fad, "[n]");
		mFace.put(R.drawable.fangdj, "[o]");
		mFace.put(R.drawable.feiw, "[p]");
		mFace.put(R.drawable.fengy, "[q]");
		mFace.put(R.drawable.ganb, "[r]");
		mFace.put(R.drawable.ganm, "[s]");
		mFace.put(R.drawable.good, "[t]");
		mFace.put(R.drawable.guil, "[u]");
		mFace.put(R.drawable.guz, "[v]");
		mFace.put(R.drawable.hany, "[w]");
		mFace.put(R.drawable.heil, "[x]");
		mFace.put(R.drawable.huaix, "[]");
		mFace.put(R.drawable.hudj, "[y]");
		mFace.put(R.drawable.jiay, "[z]");
		mFace.put(R.drawable.jinge, "[A]");
		mFace.put(R.drawable.kaf, "[B]");
		mFace.put(R.drawable.kaih, "[C]");
		mFace.put(R.drawable.kaixg, "[D]");
		mFace.put(R.drawable.kes, "[E]");
		mFace.put(R.drawable.know, "[F]");
		mFace.put(R.drawable.ku, "[I]");
		mFace.put(R.drawable.kul, "[J]");
		mFace.put(R.drawable.lip, "[K]");
		mFace.put(R.drawable.liul, "[M]");
		mFace.put(R.drawable.liw, "[N]");
		mFace.put(R.drawable.luoy, "[O]");
		mFace.put(R.drawable.mam, "[P]");

	}

}
